<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="/WEB-INF/c.tld"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="admin/Hui/lib/html5.js"></script>
<script type="text/javascript" src="admin/Hui/lib/respond.min.js"></script>
<script type="text/javascript" src="admin/Hui/lib/PIE_IE678.js"></script>

<![endif]-->
<link type="text/css" rel="stylesheet" href="admin/Hui/css/H-ui.css" />
<link type="text/css" rel="stylesheet"
	href="admin/Hui/css/H-ui.admin.css" />
<link type="text/css" rel="stylesheet"
	href="admin/Hui/font/font-awesome.min.css" />
<!--[if IE 7]>
<link href="admin/Hui/font/font-awesome-ie7.min.css" rel="stylesheet" type="text/css" />
<![endif]-->
<script type="text/javascript" src="admin/Hui/js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="admin/Hui/lib/layer1.9/layer.js"></script>
<title>修改商品</title>
<style>
hr {
	height: 1px;
	background-color: #F0F0F0;
}
</style>

</head>
<body>
	<script>
		$(function() {
			var protype_id = $("#parentType").val();
			var parType = $("#parType").val();
			if (protype_id != null && protype_id != "") {
				$("#parent").parent().append("<select name='protype_id' id='parent1' style='width: 200px' class='input-text'> </select>");
				$.post("product!checkType.action",
						{
							id : protype_id
						},function(data,status){
						var json = JSON.parse(data);
						if(data != 0){
							var a = "<option>== 请选择  ==</option>";
							$.each(json,function(n,obj){
								if (obj.pt_id == parType)
									a = a + "<option value='" + obj.pt_id + "' selected>" + obj.pt_name + "</option>"
								else
									a = a + "<option value='" + obj.pt_id + "'>" + obj.pt_name + "</option>"
							});
							$("#parent1").html(a);
						}
				});
			}
			$("#pro_name").on(
					"blur",
					function() {
						$.post("product!checkProduct.action", {
							pro_name : $("#pro_name").val(),
							checkPro_id : $("#checkPro_id").val()
						}, function(data, status) {
							if (data == 0) {
								$("#insert").bind(
										"click",
										function(event) {
											if ($("#pro_name") != null
													|| $("#pro_name") != "") {
												layer.msg('该用户名已存在,请重新输入');
												return false;
											}
										});
								layer.msg('该用户名已存在,请重新输入');
							}
						});
					});
			
			$("#parent").change(function(){
				var f = $(this);
				$.post("product!checkType.action",
						{
							id : $("#parent").val()
						},function(data,status){
						var json = JSON.parse(data);
						$("#parent1").remove();
						if(data != 0){
							if($("#parent1") != null)
								f.parent().append("<select name='protype_id' id='parent1' style='width: 200px' class='input-text'> </select>");
							var a = "<option>== 请选择  ==</option>";
							$.each(json,function(n,obj){
								a = a + "<option value='" + obj.pt_id + "'>" + obj.pt_name + "</option>"
							});
							$("#parent1").html(a);
						}
				});
			});
			
		});
	</script>
	<nav class="breadcrumb">
		<span><img src="admin/images/leftico01.png" /></span> 商品管理 <span
			class="c-gray en">&gt;</span> 商品管理 <span class="c-gray en">&gt;</span>修改商品
	</nav>
	<div class="pd-20">
		<div class="Huiform">
			<form action="product!update.action" method="post" enctype="multipart/form-data">
				<input type="hidden" name="pro_id" value="${product.pro_id }">
				<input type="hidden" name="checkPro_id" id="checkPro_id" value="${product.pro_id }">
				<table class="table table-bg">
					<tbody>
						<tr>
							<th width="100" class="text-r"><span class="c-red">*</span>
								商品名称：</th>
							<td><input type="text" style="width: 500px"
								class="input-text" id="pro_name" name="pro_name"
								datatype="*2-15" errormsg="商品名称范围在2-15位之间" nullmsg="商品名称不能为空" value="${product.pro_name }">
						</tr>
						
						<tr>
							<th width="100" class="text-r"><span class="c-red">*</span>
								商品图片：</th>
							<td>
							
							<span class="btn-upload form-group">
	        						<input class="input-text upload-url" type="text" 
	        						name="" id="" readonly style="width:200px">
	        						<a href="javascript:void();" class="btn btn-primary radius upload-btn">
	        						 浏览文件</a>
	        						<input type="file" multiple name="upload" class="input-file">
        						</span>
        					
						</tr>
						
						<tr>
							<th width="100" class="text-r"><span class="c-red"></span>
								</th>
							<td id="image">
								<img class="picture-thumb" height="200" src="${product.pro_url }">
        					</td>
						</tr>
						
						<tr>
							<th class="text-r"><span class="c-red">*</span>
								商品价格：</th>
							<td><input type="text" style="width: 500px"
								class="input-text" id="pro_price" name="pro_price" value="${product.pro_price }"
								datatype="/^([0-9]{1,5}.[0-9]{2})|([0-9]{1,5})/" errormsg="商品价格不符合格式" nullmsg="商品价格不能为空">
						</tr>
						
						<tr>
							<th width="100" class="text-r"><span class="c-red">*</span>
								是否有货：</th>
							<td>
								<c:if test="${product.pro_num == 1 }">
									<label> <input name="pro_num" type="radio"
									id="six_1" value="1" checked>是</label>
									 <label> <input type="radio" name="pro_num" 
									id="six_0" value="0">否</label>
								</c:if>
								<c:if test="${product.pro_num == 0 }">
									<label> <input name="pro_num" type="radio"
									id="six_1" value="1">是</label>
									 <label> <input type="radio" name="pro_num" 
									id="six_0" value="0" checked>否</label>
								</c:if>
							</td>
						</tr>
						
						<tr>
							<th class="text-r"><span class="c-red">*</span>
								商品类别：</th>
							<td style="width:100px">
								<input type="hidden" id="parentType" value="${product.proType.parent_id }">
								<input type="hidden" id="parType" value="${product.proType.pt_id }">
								<select name="parent" id="parent" style="width: 200px" class="input-text">
									<option>== 请选择  ==</option>
									<s:iterator value="ptList">
										<c:if test="${product.proType.parent_id == null && product.proType.pt_id == pt_id }">
											<option value="${pt_id }" selected>${pt_name }</option>
										</c:if>
										<c:if test="${product.proType.parent_id != null && product.proType.proType.pt_id == pt_id }">
											<option value="${pt_id }" selected>${pt_name }</option>
										</c:if>
										<c:if test="${(product.proType.parent_id == null && product.proType.pt_id != pt_id) || (product.proType.parent_id != null && product.proType.proType.pt_id != pt_id) }">
											<option value="${pt_id }">${pt_name }</option>
										</c:if>
									</s:iterator>
								</select>
							</td>
						</tr>
						
						<tr>
							<th class="text-r"><span class="c-red">*</span>
								商品简介：</th>
							<td><textarea name="pro_des" style="width: 700px" cols=""
									rows="" class="textarea" placeholder="商品简介"
									datatype="*" dragonfly="true" nullmsg="商品简介不能为空！">${product.pro_des }</textarea></td>
						</tr>
						
						<tr>
							<th class="text-r"><span class="c-red">*</span>
								商品保证说明：</th>
							<td><textarea name="pro_param" style="width: 700px" cols=""
									rows="" class="textarea" placeholder="商品保证说明"
									datatype="*" dragonfly="true" nullmsg="商品保证说明不能为空！">${product.pro_param }</textarea></td>
						</tr>

						<tr>

							<th></th>
							<td><button class="btn btn-success radius" type="submit"
									id="insert">
									<i class="icon-ok"></i> 确定
								</button> <a href="javascript:history.go(-1);"
								class="btn btn-secondary radius" id="insert"> <i
									class="icon-ok"></i> 返回
							</a></td>
						</tr>
					</tbody>
				</table>
			</form>
		</div>
	</div>
	<%-- <script type="text/javascript" src="admin/Hui/lib/jquery.min.js"></script> --%>
	<script type="text/javascript" src="admin/Hui/lib/Validform_v5.3.2.js"></script>
	<script type="text/javascript" src="admin/Hui/js/H-ui.js"></script>
	<script type="text/javascript" src="admin/Hui/js/H-ui.admin.js"></script>
	<script type="text/javascript">
		$(".Huiform").Validform();
	</script>

</body>
</html>